package com.itwill.syndromebang;

import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ViewFlipper;

public class StartActivity extends Activity {
	ViewFlipper flipper;
	ImageView imageView1, imageView2;
	Bitmap bitmap1, bitmap2;
	Timer excuteTimer;

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start_ativity);
        
        flipper = (ViewFlipper)findViewById(R.id.viewFlipper);
        imageView1 = (ImageView)findViewById(R.id.ImageView01);
        bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.itwillmain);
        imageView1.setImageBitmap(bitmap1);
        
        imageView2 = (ImageView)findViewById(R.id.ImageView02);
        bitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.helpline_1);
        imageView2.setImageBitmap(bitmap2);
        
        flipper.startFlipping();
        
		excuteTimer = new Timer("motionTimer");
		excuteTimer.schedule(new TimerTask() {
			public void run() {
				runOnUiThread(new Runnable() {
					public void run() {
				        Intent intent = new Intent();
				        intent.setClass(getApplicationContext(), LoginActivity.class);
				    	intent.setFlags(
								Intent.FLAG_ACTIVITY_CLEAR_TASK |
								Intent.FLAG_ACTIVITY_NEW_TASK);
				        flipper.stopFlipping();
				        startActivity(intent);
				       
					}
				});
			}
		}, 4000);
		
    }

	@Override
	protected void onDestroy() {
		super.onDestroy();
		excuteTimer.cancel();
		System.gc();
	}
}
